﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DuplexClient.CalculatorDuplex;
using System.ServiceModel;

namespace DuplexClient
{
    public class CallbackHandler : ICalculatorDuplexCallback
    {

        public void Equals(double result)
        {
            Console.WriteLine("Result({0})", result.ToString());
        }

        public void Equation(string eqn)
        {
            Console.WriteLine("Equation({0})", eqn);
        }
    }

    public class Program
    {
        static void Main(string[] args)
        {
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
            CalculatorDuplexClient sc = new CalculatorDuplexClient(instanceContext, "NetTcpBinding_ICalculatorDuplex");

            Console.WriteLine("press <enter> to terminate client once the output is displayed.");

            Console.WriteLine();
            double value = 100.00D;
            sc.AddTo(value);

            value = 50.00D;
            sc.SubtractFrom(value);

            value = 10.00D;
            sc.MultiplyBy(value);

            value = 2.00D;
            sc.DivideBy(value);
            sc.Clear();

            Console.ReadLine();
            sc.Close();

        }
    }
}
